//
//  vdView.h
//  Void Dead
//
//  Created by Sidney Just on 16.11.09.
//
//  Copyright © 2009 by Sidney Just
//  Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated 
//  documentation files (the "Software"), to deal in the Software without restriction, including without limitation 
//  the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, 
//  and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
//  The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
//  THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, 
//  INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR 
//  PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE 
//  FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, 
//  ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//

#import <UIKit/UIKit.h>

#import "vdHeader.h"
#import "vdColor.h"
#import "vdTexNode.h"
#import "vdRenderer.h"
#import "vdEventHandler.h"

/**
 * This class represents the base structure for any render view. The framebuffer will be flushed on this view.
 **/
@interface vdView : UIView {
	//\cond
	GLint backingWidth;
    GLint backingHeight;
	
	NSTimeInterval deltaTime;
	
	UIInterfaceOrientation orientation;
	
	vdColor *clearColor;
	
	/**
	 * The rendering context
	 **/
	EAGLContext *context;

	/**
	 * Handle to the Renderbuffer
	 **/
    GLuint viewRenderbuffer; 
	
	GLuint viewFramebuffer;
	//\endcond
	
	@private
	CGPoint *oldTouches;
	int oldTouchesCount;
}

/**
 * Handle to the Framebuffer
 **/
@property (readonly) GLuint viewFramebuffer;

/**
 * The orientation of the view as UIKit orientation.
 **/
@property UIInterfaceOrientation orientation;

/**
 * The time thats passed since the last frame.
 **/
@property NSTimeInterval deltaTime;

/**
 * The width of the backbuffer in pixels.
 **/
@property GLint backingWidth;

/**
 * The height of the backbuffer in pixels.
 **/
@property GLint backingHeight;

/**
 * The colorbuffer will be cleared with this color
 **/
@property vdColor *clearColor;

/**
 * Prepares the rendering (clearing the screen with the clear color, sets the rendering context and so on)
 **/
- (void)prepareRendering;

/**
 * Swaps the buffer.
 **/
- (void)completeRendering;

/**
 * Binds the default framebuffer.
 **/
- (void)bindFramebuffer;

@end
